﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace YJKRevitDimensionText.OneKeyPlanDim.Utility
{
	public class CommonDirectionLevelDimDataInfo
	{
		public CommonDirectionLevelDimDataInfo(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			this.m_lstSingleLevelDimDataInfo.Add(singleLevelDimDataInfo);
			this.m_dir = singleLevelDimDataInfo.DimDir.Normalize();
		}

		public SingleLevelDimDataInfo CenterDimFirst
		{
			get
			{
				return this.m_CenterDimFirst;
			}
		}

		public List<SingleLevelDimDataInfo> LstSingleLevelDimDataInfo
		{
			get
			{
				return this.m_lstSingleLevelDimDataInfo;
			}
		}

		public bool IsCommonDir(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			return this.m_dir.IsAlmostEqualTo(singleLevelDimDataInfo.DimDir.Normalize());
		}

		public void AddElement(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			this.m_lstSingleLevelDimDataInfo.Add(singleLevelDimDataInfo);
		}

		public List<SingleLevelDimDataInfo> SortSingleLevelDimDataInfo
		{
			get
			{
				return this.m_lstSingleLevelDimDataInfo;
			}
		}

		public void SortOperator()
		{
			this.m_lstSingleLevelDimDataInfo.Sort(new LocationComparer());
			int count = this.m_lstSingleLevelDimDataInfo.Count;
			if (count == 0)
			{
				return;
			}
			this.m_CenterDimFirst = this.m_lstSingleLevelDimDataInfo[count / 2];
			this.m_lstSingleLevelDimDataInfo.Sort(new LocationComparer(this.m_CenterDimFirst.PtLocation));
		}

		private XYZ m_dir;

		private List<SingleLevelDimDataInfo> m_lstSingleLevelDimDataInfo = new List<SingleLevelDimDataInfo>();

		private SingleLevelDimDataInfo m_CenterDimFirst;
	}
}
